package com.netdisk.demo.security;

import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.io.Serializable;
import java.util.Collection;
/**
 * @Author Wang
 * @Description  * Spring Security UserDetails接口类，继承UserDetails，用于身份认证
 * @Date 22:23 2020/5/10
 */
public class MyUserDetails implements UserDetails {
        private static final long serialVersionUID = 608139498943511669L;

        private String userName;

        private String password;

        private Collection<? extends GrantedAuthority> authorities;


        public void setAuthorities(Collection<? extends GrantedAuthority> authorities) {
           this.authorities = authorities;
        }

        public void setUserName(String userName) {
            this.userName = userName;
        }

        public void setPassword(String password) {

            this.password = password;
        }

        @Override//获取密码
        public String getPassword() {

            return this.password;
        }

        @Override//获取用户名
        public String getUsername() {
            return this.userName;
        }

        @Override//用户权限
        public Collection<? extends GrantedAuthority> getAuthorities() {
            return this.authorities;
        }

        @Override//用户是否启用过期，本项目不涉及，故返回真，下同
        public boolean isAccountNonExpired() {
            return true;
        }

        @Override//用户凭证是否启用过期
        public boolean isCredentialsNonExpired() {
            return true;
        }

        @Override//用户是否启用
        public boolean isEnabled() {
            return true;
        }

        @Override
        public boolean isAccountNonLocked() {
            return true;
        }
}
